The ImagePresenter manages the varying state and conditions of use of QuickTime's DSequence renderer. It is a useful abstraction because it hides such details from the user, creating a robust and reusable class.
The ImagePresenter is able to render its data faster than its corollary GraphicsImporterDrawer , which also implements the QTDrawable interface, for two reasons. First, the data is kept in memory and so it is quicker to read. (The GraphicsImporterDrawer reads its image data from its DataRef , typically a file.) Second, the image data of an ImagePresenter can be (and often is) kept in a format that is optimized for rendering or decompression. However, a GraphicsImporterDrawer will use less memory and is often more than sufficient for presenting an image where no demanding rendering tasks are required, such as constant, time-sensitive redrawing.
An ImagePresenter object can be created from many sources. For example, from a file:
ImagePresenter myImage = ImagePresenter.fromFile(imageFile);
In this case, the ImagePresenter will create a GraphicsImporter to read and load into memory the image data from the file. It will then decompress the image if necessary to a format optimized for rendering.
You can also create an ImagePresenter from generated image data and an ImageDescription that describes it:
int width = 100;
int height = 100;
IntEncodedImage myImageData = new IntEncodedImage (width * height);
//...fill in pixel values using standard java ARGB ordering
ImageDescription myDescription =
ImageDescription.getJavaDefaultPixelDescription (width,
height);
myDescription.setDataSize (myImageData.getSize());
ImagePresenter myPresenter = ImagePresenter.fromQTImage(myImageData,
myDescription);
You can also create an ImagePresenter object from an onscreen or offscreen QDGraphics that you have previously drawn into:
QDGraphics gWorld = ....
Rect rect = ....
int colorDepth = ....
int quality = ....
int codecType = ....
CodecComponent codec = ....
ImagePresenter myIP = ImagePresenter.fromGWorld (myGWorld,
myGWorld.getBounds(),
myGWorld.getPixMap().getPixelSize(),
myDerivedCompressionQuality,
myDerivedCompressionType,
myDerivedCodecComponent);
| Previous | Chapter Top | Chapter Contents | Next |